package com.inspur.cloud.util;

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.io.ClassPathResource;

/**
 * 从yml配置文件中读取配置
 */
public class YamlUtil {

    public  static String getProperty(String key){
        return getProperty("application.yml",key);
    }

    public static String getProperty(String yamlFile,String key){
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        yaml.setResources(new ClassPathResource(yamlFile));
        return yaml.getObject().getProperty(key);
    }
}
